package com.onlyMe.config
{
	public class BaseNode
	{
		public function BaseNode()
		{
		}
		
		// To Override
		
		protected virtual function extract(node:XML):void
		{
		}
		
		protected virtual function extractChild(node:XML):void
		{
		}
		
		// Utils
		
		protected function boolean(value:String):Boolean
		{
			if (value === 'true')
				return true;
			if (value === 'false')
				return false;
			throw new Error(value + ' is not a valid boolean value');
		}
		
		// Final
		
		public final function decode(node:XML):*
		{
			extract(node);
			
			for each (var child:XML in node.children())
				extractChild(child);
			
			return this;
		}
	}
}